package priv.abadstring.study.haoke.webapi.controller;

import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import priv.abadstring.study.haoke.webapi.config.MockConfig;

/**
 * MockController
 *
 * @author aBadString
 * @date 2021-06-19 17:08:14
 */
@RequestMapping("mock")
@RestController
@CrossOrigin
public class MockController {
    private final MockConfig mockConfig;
    public MockController(MockConfig mockConfig) {
        this.mockConfig = mockConfig;
    }

    /**
     * 菜单
     */
    @GetMapping("index/menu")
    public String indexMenu() {
        return this.mockConfig.getIndexMenu();
    }
    /**
     * 首页资讯
     */
    @GetMapping("index/info")
    public String indexInfo() {
        return this.mockConfig.getIndexInfo();
    }
    /**
     * 首页问答
     */
    @GetMapping("index/faq")
    public String indexFaq() {
        return this.mockConfig.getIndexFaq();
    }
    /**
     * 首页房源信息
     */
    @GetMapping("index/house")
    public String indexHouse() {
        return this.mockConfig.getIndexHouse();
    }
    /**
     * 查询资讯
     */
    @GetMapping("infos/list")
    public String infosList(@RequestParam("type") Integer type) {
        switch (type){
            case 1:
                return this.mockConfig.getInfosList1();
            case 2:
                return this.mockConfig.getInfosList2();
            case 3:
                return this.mockConfig.getInfosList3();
            default:
                return this.mockConfig.getInfosList1();
        }
    }
    /**
     * 我的中心
     */
    @GetMapping("my/info")
    public String myInfo() {
        return this.mockConfig.getMy();
    }
}